<template>
	<div>
		<el-form ref="form" :model="form" label-width="80px">

			<el-form-item label="姓名">
				<el-input v-model="form.name"></el-input>
			</el-form-item>


			<el-form-item label="年龄">
				<el-input v-model="form.age"></el-input>
			</el-form-item>

			<el-form-item label="性别">
				<el-input v-model="form.gender"></el-input>
			</el-form-item>
			<el-form-item label="评估医生">
				<el-input v-model="form.evaluationDoctor"></el-input>
			</el-form-item>
			
			<el-form-item label="责任医生">
				<el-input v-model="form.responsibleDoctor"></el-input>
			</el-form-item>
			
			<el-form-item label="健康管家">
				<el-input v-model="form.healthButler"></el-input>
			</el-form-item>
			
			<el-form-item label="楼房">
				<el-input v-model="form.building"></el-input>
			</el-form-item>
			
			<el-form-item label="床号">
				<el-input v-model="form.bedNum" ></el-input>
			</el-form-item>
			
			<el-form-item label="入住时间">
				<el-input v-model="form.checkInTime" value-format="yyyy-MM-dd" type="date"></el-input>
			</el-form-item>
			
			<el-form-item label="合同到期时间">
				<el-input v-model="form.expirationTime" value-format="yyyy-MM-dd" type="date"></el-input>
			</el-form-item>
			
			<el-form-item label="身体状况简述">
				<el-input v-model="form.physicalCondition"></el-input>
			</el-form-item>
			
			<el-form-item label="紧急联系人">
				<el-input v-model="form.emergencyContact"></el-input>
			</el-form-item>
			
			<el-form-item label="联系人电话">
				<el-input v-model="form.contactPhone"></el-input>
			</el-form-item>
			
			<el-form-item label="评估结果">
				<el-input v-model="form.assessmentResults"></el-input>
			</el-form-item>
			
			<el-form-item>
				<el-button type="primary" @click="save">保存</el-button>
			</el-form-item>
		</el-form>

	</div>
</template>

<script>
	export default {
		name: 'CustomerInformationEdit',
		components: {
			
		},
		props: [
			'show',
			'editid'
		],
		data() {
			return {
				form: {
					id: '',
					username: '',
					age: '',
					gender: '',
					evaluationDoctor: '',
					responsibleDoctor: '',
					healthButler: '',
					building: '',
					bedNum: '',
					checkInTime: '',
					expirationTime: '',
					physicalCondition: '',
					careLevel: '',
					emergencyContact: '',
					contactPhone: '',
					assessmentResults: '',
					
				},
				depts:[],
				registLevels:[]
				// depts:[
				// 	{id:1,name:'肾内科'},
				// 	{id:2,name:'消化内科'}
				// ],
				// registLevls:[
				// 	{id:1,name:'专家'},
				// 	{id:2,name:'教授'}
				// ]
			}
		},
		created() {
			if (this.editid){
				this.show = true;
				this.$axios.get(
					'customerInformation/update',
					response=> {
						this.form.id = this.editid;
						this.form.username = response.obj.username;
						this.form.age = response.obj.age;
						this.form.gender = response.obj.gender;
						this.form.evaluationDoctor = response.obj.evaluationDoctor;
						this.form.responsibleDoctor = response.obj.responsibleDoctor;
						this.form.healthButler = response.obj.healthButler;
						this.form.building = response.obj.building;
						this.form.bedNum = response.obj.bedNum;
						this.form.checkInTime = response.obj.checkInTime;
						this.form.expirationTime = response.obj.expirationTime;
						this.form.physicalCondition = response.obj.physicalCondition;
						this.form.careLevel = response.obj.careLevel;
						this.form.emergencyContact = response.obj.emergencyContact;
						this.form.contactPhone = response.obj.contactPhone;
						this.form.assessmentResults = response.obj.assessmentResults;
					},{
						id: this.editid
					}
				)
			}
		},
		getNowFormatDate() {
		    var date = new Date();
		    var seperator1 = "-";
		    var seperator2 = ":";
		    var month = date.getMonth() + 1;
		    var strDate = date.getDate();
		    if (month >= 1 && month <= 9) {
		        month = "0" + month;
		    }
		    if (strDate >= 0 && strDate <= 9) {
		        strDate = "0" + strDate;
		    }
		    var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
		            + " " + date.getHours() + seperator2 + date.getMinutes()
		            + seperator2 + date.getSeconds();
		    return currentdate;
		},
		methods: {
			save() {
				this.axios.get('/customerInformation/toAdd', (data) => {
					if (data) {
						this.$emit('update:show', false)
						this.$emit('getData')
					}

				},this.form,'保存成功');
			},
		// 	loadData(){
		// 		//加载机构列表
		// 		this.axios.get('/dept?type=listAll', (data) => {
		// 			this.depts = data;
		// 		});
				
		// 		//加载机构列表
		// 		this.axios.get('/regist_level?type=queryList', (data) => {
		// 			this.registLevels = data;
		// 		});
		// 	}
			
			
			
		// },
		// created() {

		// 	if (this.userId) {
		// 		//当修改的时候 需要根据用户的 id， 将数据查询到页面
		// 		this.axios.get('/user?type=toEdit', (data) => {
		// 			this.form = data;
		// 		}, {
		// 			userId: this.userId
		// 		});
		// 	}
			
			//加载 科室、挂号级别信息
			// this.loadData();

		}
	}
</script>

<style>
</style>
